﻿<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Uc_staff_list.ascx.vb"
    Inherits="Apps_Shares_Uc_staff_list" %>
<%--==============================BEGIN Filter==============================--%>
<%--==============================END Filter==============================--%>
<table width="50%" border="1" align="center" cellpadding="2" cellspacing="2" bordercolor="#999999">
    <tr align="center" bgcolor="#99FFFF">
        <td colspan="2" bgcolor="#FFFFFF" class="th_data">
            ค้นหาข้อมูล
        </td>
    </tr>
    <tr align="left">
        <td width="47%" bordercolor="#CCCCCC" class="td_box">
            คำที่ต้องการค้นหา :
        </td>
        <td width="53%" bordercolor="#CCCCCC" class="td_box">
            <asp:TextBox ID='txtKeyword' runat='server'></asp:TextBox>
        </td>
    </tr>
    <tr align="left">
        <td width="47%" bordercolor="#CCCCCC" class="td_box">
            ประเภทที่ต้องการค้นหา :
        </td>
        <td width="53%" bordercolor="#CCCCCC" class="td_box">
            <asp:DropDownList ID='ddlFilterType' runat='server'>
                <asp:ListItem Text='ประเภทที่ต้องการค้นหา' Value='0'></asp:ListItem>
                <asp:ListItem Text='ชื่อ' Value='1'></asp:ListItem>
                <asp:ListItem Text='นามสกุล' Value='2'></asp:ListItem>
                <asp:ListItem Text='เลขประจำตัวพนักงาน' Value='3'></asp:ListItem>
            </asp:DropDownList>
        </td>
    </tr>
    <tr align="left">
        <td width="47%" bordercolor="#CCCCCC" class="td_box">
            หน่วยงานที่สังกัด :
        </td>
        <td width="53%" bordercolor="#CCCCCC" class="td_box">
            <asp:DropDownList ID='ddlDependDepartment' runat='server' AppendDataBoundItems="True"
                DataTextField="department_name" DataValueField="department_code" AutoPostBack="True"
                DataSourceID="ddlStpDepartmentSrc">
                <asp:ListItem Text='หน่วยงานที่สังกัด' Value='0'></asp:ListItem>
            </asp:DropDownList>
            <asp:ObjectDataSource ID="ddlStpDepartmentSrc" runat="server" SelectMethod="GetStpDepartmentByPrivilege"
                TypeName="CodeMatrix.Business.GenericData"></asp:ObjectDataSource>
            <%--
                <asp:SqlDataSource ID="srcDepartmentCode" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
                    SelectCommand="USP_GetDepartmentHirachy" SelectCommandType="StoredProcedure">
                </asp:SqlDataSource>--%>
        </td>
    </tr>
    <tr align="left">
        <td width="47%" bordercolor="#CCCCCC" class="td_box">
            กลุ่มผู้ใช้งาน :
        </td>
        <td width="53%" bordercolor="#CCCCCC" class="td_box">
            <asp:DropDownList ID='ddlUserGroup' runat='server' DataTextField="group_user_name"
                DataValueField="group_user_code">
                <asp:ListItem Text='กลุ่มผู้ใช้งาน' Value='0'></asp:ListItem>
            </asp:DropDownList>
        </td>
    </tr>
    <tr align="left">
        <td width="47%" bordercolor="#CCCCCC" class="td_box">
            สถานะ :
        </td>
        <td width="53%" bordercolor="#CCCCCC" class="td_box">
            <asp:DropDownList ID='ddlStatus' runat="server">
                <asp:ListItem Text='สถานะ' Value='0'></asp:ListItem>
                <asp:ListItem Text='มีสิทธิ์เข้าใช้งาน' Value='1'></asp:ListItem>
                <asp:ListItem Text='ไม่มีสิทธิ์เข้าใช้งาน' Value='2'></asp:ListItem>
            </asp:DropDownList>
        </td>
    </tr>
    <tr align="center">
        <td colspan="2" bordercolor="#CCCCCC" class="td_data_end">
            <asp:Button ID='btnFilter' Text='<%$ Resources:Resource,BTN_SEARCH %>' runat='server' />
            <asp:Button ID='btnMainMenu' Text='<%$ Resources:Resource,BTN_MAINMENU %>' runat='server' PostBackUrl="~/Apps/ViewSystem.aspx?Edit=2" />
        </td>
    </tr>
</table>
<div style="margin:5px;display:block;width:100%">&nbsp;</div>
<%--==============================BEGIN Gridview==============================--%>
<span class='component_caption'>
    <asp:Literal ID='ltrCountView' runat='server' Text=''></asp:Literal></span>
<asp:ListView ID="gvDisplay" runat="server" DataSourceID="srcSearch" EnableModelValidation="True"
    DataKeyNames='staff_code'>
    <LayoutTemplate>
        <table cellspacing="2" cellpadding="2" bordercolor="#999999" border="0" align="center"
            width="100%">
            <tbody>
                <tr bgcolor="#ff9999" align="center">
                    <td bgcolor="#ffffff" class="th_data">
                        <asp:Image ID="staff_no" runat="server" Visible="false" />
                        <asp:LinkButton ID='sort2' runat='server' CommandName='Sort' CommandArgument='staff_no'>
                                เลขประจำตัว
                        </asp:LinkButton>
                    </td>
                    <td bgcolor="#ffffff" class="th_data">
                        <asp:Image ID="fullname" runat="server" Visible="false" />
                        <asp:LinkButton ID='sort3' runat='server' CommandName='Sort' CommandArgument='fullname'>
                                ชื่อ - นามสกุล
                        </asp:LinkButton>
                    </td>
                    <td bgcolor="#ffffff" class="th_data">
                        <asp:Image ID="group_user_name" runat="server" Visible="false" />
                        <asp:LinkButton ID='sort4' runat='server' CommandName='Sort' CommandArgument='group_user_name'>
                                กลุ่มผู้ใช้งาน
                        </asp:LinkButton>
                    </td>
                    <td bgcolor="#ffffff" class="th_data">
                        <asp:Image ID="department_hirachy" runat="server" Visible="false" />
                        <asp:LinkButton ID='sort5' runat='server' CommandName='Sort' CommandArgument='department_hirachy'>
                                หน่วยงานที่สังกัด
                        </asp:LinkButton>
                    </td>
                    <td bgcolor="#ffffff" class="th_data">
                        <asp:Image ID="status" runat="server" Visible="false" />
                        <asp:LinkButton ID='sort6' runat='server' CommandName='Sort' CommandArgument='status'>
                                สถานะ
                        </asp:LinkButton>
                    </td>
                    <td bgcolor="#ffffff" class="th_data col_delete">
                        <input id='icbHeader' type='checkbox' />
                        ลบข้อมูล
                    </td>
                </tr>
                <asp:PlaceHolder ID='itemPlaceholder' runat='server' />
                <tr bgcolor="#ff9999" align="center">
                    <td bgcolor="#ffffff" class="td_data_end" colspan="5">
                        <%-- ====================== Data Pager ======================--%>
                        <asp:DataPager ID="paging" runat="server" PagedControlID="gvDisplay" PageSize='10'>
                            <Fields>
                                <asp:NextPreviousPagerField ShowFirstPageButton="true" ShowLastPageButton="false"
                                    ShowNextPageButton='false' ShowPreviousPageButton='false' FirstPageText='<<' />
                                <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="false"
                                    ShowNextPageButton='false' ShowPreviousPageButton='true' PreviousPageText='<' />
                                <asp:NumericPagerField />
                                <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="false"
                                    ShowNextPageButton='true' ShowPreviousPageButton='false' NextPageText='>' />
                                <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="true"
                                    ShowNextPageButton='false' ShowPreviousPageButton='false' LastPageText='>>' />
                            </Fields>
                        </asp:DataPager>
                        <%-- ====================== Data Pager ======================--%>
                    </td>
                    <td bgcolor="#ffffff" class="td_data_end col_delete">
                        <asp:Button ID='btnDelete' runat='server' Text='ลบข้อมูล' OnClick='btnDelete_Click'
                            OnClientClick='<%$Resources:Resource,SCRIPT_CONFIRM_DELETE %>' />
                    </td>
                </tr>
            </tbody>
        </table>
    </LayoutTemplate>
    <EmptyDataTemplate>
        <br />
        <span class='star'>
            <center>ไม่พบข้อมูล</center>
        </span>
    </EmptyDataTemplate>
    <ItemTemplate>
        <tr>
            <td align="left" class="td_data" bordercolor="#CCCCCC">
                <a href='<%# "staff_fv.aspx?Edit=" & Eval("staff_code") & CodeMatrix.Business.GenericData.GetViewMode() %>'>
                    <%# Eval("staff_no")%>
                </a>
            </td>
            <td align="left" class="td_data" bordercolor="#CCCCCC">
                &nbsp;<%# Eval("fullname")%>
            </td>
            <td align="left" class="td_data" bordercolor="#CCCCCC">
                &nbsp;<%# Eval("group_user_name")%>
            </td>
            <td align="left" class="td_data" bordercolor="#CCCCCC">
                &nbsp;
                <%#Eval("department_hirachy")%>
            </td>
            <td align="center" class="td_data f_status" bordercolor="#CCCCCC">
                &nbsp;<%# Eval("status")%>
            </td>
            <td align="center" class="td_data col_delete" bordercolor="#CCCCCC">
                &nbsp;<asp:CheckBox ID='icbItem' runat='server' />
            </td>
        </tr>
    </ItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="srcSearch" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
    SelectCommand="EXEC USP_GetListStaff @filterType, @staff_firstname, @staff_lastname, @staff_no, @group_user_code, @department_code, @staff_status, @ctx_staff_code"
    DeleteCommand="EXEC  [dbo].[USP_GenericDelete] @tbl,@pid,@cid">
    <DeleteParameters>
        <asp:Parameter DefaultValue="staff" Name="tbl" Type="String" />
        <asp:Parameter DefaultValue="staff_code" Name="pid" Type="String" />
        <asp:Parameter DefaultValue="" Name="cid" Type="String" />
    </DeleteParameters>
    <SelectParameters>
        <asp:ControlParameter ControlID="ddlFilterType" Name="filterType" PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="txtKeyword" ConvertEmptyStringToNull="False" Name="staff_firstname"
            PropertyName="Text" />
        <asp:ControlParameter ControlID="txtKeyword" ConvertEmptyStringToNull="False" Name="staff_lastname"
            PropertyName="Text" />
        <asp:ControlParameter ControlID="txtKeyword" ConvertEmptyStringToNull="False" Name="staff_no"
            PropertyName="Text" />
        <%--<asp:ControlParameter ControlID="ddlUserGroup" Name="group_user_code" PropertyName="SelectedValue" />--%>
        <%--<asp:ControlParameter ControlID="ddlDependDepartment" Name="department_code" 
            PropertyName="SelectedValue" />--%>
        <asp:Parameter Name="group_user_code" />
        <asp:Parameter Name="department_code" />
        <asp:ControlParameter ControlID="ddlStatus" Name="staff_status" PropertyName="SelectedValue" />
        <asp:SessionParameter Name="ctx_staff_code" SessionField="staff_code" />
    </SelectParameters>
</asp:SqlDataSource>
<%--==============================END Gridview==============================--%>
<%--==============================To mark all check box==============================--%>

<script type="text/javascript">
    matchTableCheckBox('icbHeader', 'icbItem');
    hideDeleteColumn();
    hilightInactive();
</script>

